let inputEle = document.getElementsByClassName('input')[0]
let btnEle = document.getElementsByClassName('btn')[0]

inputEle.onblur = function(){
  if(inputEle.value && inputEle.value !== ''){
    btnEle.disabled = false
  }
}
btnEle.onclick = function(){
  $.ajax({//*发送请求到后端，将用户名传到后端
    type:'get',
    url:'http://localhost:30001/user/setCookie',
    data:{username:inputEle.value},
    success:function(result) {//*通过result拿到返回值如果成功则跳转到chat页面
      if(result.status === 'success') {
        location.href = '/user/chat'
      }
    }
  })
}

